import * as Types from '../constant/ActionTypes';
import {clear} from 'src/utils/auth';

const initialState = {
  info: { username: '查询中...' },
};

const user = (state = initialState, action = {}) => {
  switch (action.type) {
    case Types.USER_LOGIN:
      state.info = action.payload;
      return { ...state };
    case Types.CLEAR_AUTH:
      clear();
      state.info = {};
      return {...state};
    default:
      return state;
  }
};

export default user;